package com.ruoyi.common.core.page;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述 APP分页封装对象
 * 作者 ZhangPing
 * 创建时间 2023/8/21 16:18
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
@Accessors(chain = true)
public class AppPage<T> {

    private long total;
    private long pageIndex;
    private long pageSum;
    private List<T> rows = new ArrayList<>();

    public AppPage(PageInfo<T> page){
        this.total = page.getTotal();
        this.pageIndex = page.getPageNum();
        this.pageSum = page.getPageSize();
        this.rows = page.getList();
    }

    public AppPage(long pageIndex, long pageSum) {
        this.pageIndex = pageIndex;
        this.pageSum = pageSum;
    }

}
